{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. Network Layering" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Previously I suggested these two layers of networks (I have renamed them here):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.1 Sensor-space Sequence Network" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "+---------------------+ +------------+\n", "| sensor_t1 | | motor_t0 |\n", "+---------------------+ +------------+\n", " ^ ^\n", " +---------------------+\n", " | hidden_t0 |\n", " +---------------------+\n", " ^ ^\n", "+---------------------+ +------------+\n", "| sensor_t0 | | motor_t0 |\n", "+---------------------+ +------------+\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.2 Hidden-space Sequence Network" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " +---------------------+ \n", " | hidden_t1 | \n", " +---------------------+ \n", " ^\n", " +-----------------+\n", " | hidden2_t0 |\n", " +-----------------+\n", " ^ ^\n", "+---------------------+ +---------------------+ \n", "| hidden_t0 | | hidden_goal | \n", "+---------------------+ +---------------------+ \n", "\n", "\n", "Comparing these two networks, one notices some symmetry:\n", "\n", "* both take state and control, and produces next state\n", " * hidden_t0 plays the role of sensor_t0 in the Hidden-space network\n", " * hidden_goal plays the role of motor_t0 in the Hidden-space network\n", " \n", "This also suggests a slight variation of the Hidden-space network:\n", "\n", "
\n", " +---------------------+ +---------------------+ \n", " | hidden_t1 | | hidden_goal | \n", " +---------------------+ +---------------------+ \n", " ^ ^\n", " +-----------------+\n", " | hidden2_t0 |\n", " +-----------------+\n", " ^ ^\n", "+---------------------+ +---------------------+ \n", "| hidden_t0 | | hidden_goal | \n", "+---------------------+ +---------------------+ \n", "\n", "\n", "What does that give you?\n", "\n", "* complete symmetry (who cares?)\n", "* the possibility of doing what we did with Sensor-space Network to the Hidden-space Network\n", " * that would give us the possibility of sequencing goals\n", " * and that is repeatable (eg, more networks doing higher level planning)\n", "\n", "Note: to use at a higher-level Hidden-Hidden-Space Sequence Network we will need a goal-no-op to get started." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Training" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from IPython.display import display, HTML\n", "import theano.tensor as T\n", "import numpy as np\n", "import sys\n", "sys.path.append(\"..\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using TensorFlow backend.\n" ] } ], "source": [ "from discover import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We import the discover program and load the experiment we are interested in:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "FLAGS.directory = \"../results\" # Where to save/restore files\n", "FLAGS.mode = 'test' # Should be 'wander' or 'test'\n", "FLAGS.num_steps = 5000 # Number of steps to wander and learn\n", "FLAGS.num_hiddens = 10 # Number of hidden units in model" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "____________________________________________________________________________________________________\n", "Layer (type) Output Shape Param # Connected to \n", "====================================================================================================\n", "g_in (InputLayer) (None, 10) 0 \n", "____________________________________________________________________________________________________\n", "s_in (InputLayer) (None, 19) 0 \n", "____________________________________________________________________________________________________\n", "m_in (InputLayer) (None, 2) 0 \n", "____________________________________________________________________________________________________\n", "c_in (InputLayer) (None, 10) 0 \n", "____________________________________________________________________________________________________\n", "merge_1 (Merge) (None, 41) 0 \n", "____________________________________________________________________________________________________\n", "h (Dense) (None, 10) 420 \n", "____________________________________________________________________________________________________\n", "g_out (Dense) (None, 10) 110 \n", "____________________________________________________________________________________________________\n", "s_out (Dense) (None, 19) 209 \n", "____________________________________________________________________________________________________\n", "m_out (Dense) (None, 2) 22 \n", "====================================================================================================\n", "Total params: 761.0\n", "Trainable params: 761.0\n", "Non-trainable params: 0.0\n", "____________________________________________________________________________________________________\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "../discover.py:78: UserWarning: The `merge` function is deprecated and will be removed after 08/2017. Use instead layers from `keras.layers.merge`, e.g. `add`, `concatenate`, etc.\n", " x = merge([g_in, s_in, m_in, c_in], mode='concat')\n", "/usr/local/lib/python3.5/dist-packages/keras/legacy/layers.py:456: UserWarning: The `Merge` layer is deprecated and will be removed after 08/2017. Use instead layers from `keras.layers.merge`, e.g. `add`, `concatenate`, etc.\n", " name=name)\n", "../discover.py:83: UserWarning: Update your `Model` call to the Keras 2 API: `Model(outputs=[